package com.nacos.nacosproducer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @author wenl
 * @version V2.0
 * @project 自己的框架
 * @package com.nacos.nacosproducer
 * @date 2020/4/13
 * @describe
 */

@RestController
@RequestMapping("/string")
public class RedisStringController {

//    @Autowired
//    private StringRedisTemplate redisTemplate;

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @GetMapping(value = "/put")
    public void put(String key, String value){
        User user = new User(1,value);
        redisTemplate.opsForValue().set(key,user);
    }

    @GetMapping(value = "/get")
    public Object get(String key){
        return redisTemplate.opsForValue().get(key);
    }


}
